<?php

/*
 * hanv: detect mobile
 */
include_once 'Mobile_Detect.php';
$web_touch_version_domain = 'm.igniteapplication.com';
if ($_SERVER['HTTP_HOST'] == $web_touch_version_domain) {
    return;
}

$detect = new Mobile_Detect();
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
//detect follow OS phone: use for both phone, tablet
if ($detect->isMobile()) {
//Redirect to touch version
    if (strpos($actual_link, "m.igniteapplication.com") === false) {

        $url = str_replace("igniteapplication.com", "m.igniteapplication.com", $actual_link);
        header('Location:' . $url);
    }
} else {
    if (strpos($actual_link, "m.igniteapplication.com") !== false) {
        $url = str_replace("m.igniteapplication.com", "igniteapplication.com", $actual_link);

        header('Location:' . $url);
    }
}
?>
